#ifndef MAP_H
#define MAP_H


#include "Cell.h"

    const int NUM_CELLS = 1000000;
    Cell Map1[NUM_CELLS];
void Createinfo()
{
     
     cout << "\n\nCreating the Map\n\n";
     cout << "\n\nSuccesfully created the Map... puuh!\n\n";
     cout << "It contains " << NUM_CELLS << " cells\n\n";
     return;
}

void Load()
{
     cout << "\n\nLoading the Map settings...\n\n";
     ifstream Mapfile;
     string line;
     int a=0,b=0;
     Mapfile.open ("Cells.txt");
     if (Mapfile.fail())        // this checks if it loads right?
     {
        cout << "Failed load"; 
        return;
        }
     
     else{
          while(getline(Mapfile,line))
          {
                    stringstream(line) >> a;
                    Map1[b].Settype(a);
                    getline(Mapfile,line);
                    stringstream(line) >> a;
                    Map1[b].Setproduction(a);
                    ++b;
          }
     
     }
     cout << "Load successful\n\n";
     return;
}

void Save()
{
     cout << "\n\nSaving the Map... This might take a while.\n\n";
     ofstream Mapfile;
     string line;
     int a=0;
     Mapfile.open("Cells.txt");
     if (Mapfile.fail())       //checks if it loads correctly     
     {
        cout << "Failed Save\n\n"; 
        return;
        }
     
     else{
          while(a < NUM_CELLS)
          {
                  Mapfile << Map1[a].Gettype() << endl;
                  Mapfile << Map1[a].Getproduction() << endl;
                  ++a;
                                       
          }
     
     }
     cout << "Save successful\n\n";
     return;
}
#endif
